package com.why.jvm.hotspot.src.share.vm.oops.constants;

import lombok.Data;

/**
 * @author xiaoTian
 * @date 2022/7/22 14:33
 * @Description:
 */
@Data
public class ConstantNameAndTypeInfo extends ConstantInfoBase{

    private int nameIndex;

    private int descriptorIndex;

    public String getName(){
        ConstantUtf8Info constantUtf8Info = (ConstantUtf8Info) getConstantPool().getConstantPoolMap().get(nameIndex);
        return constantUtf8Info.getValue();
    }

    public String getDescriptorValue(){
        ConstantUtf8Info constantUtf8Info = (ConstantUtf8Info)  getConstantPool().getConstantPoolMap().get(descriptorIndex);
        return constantUtf8Info.getValue();
    }

    @Override
    public String toString() {
        return "ConstantNameAndTypeInfo{" +
                "nameIndex=" + nameIndex +
                ", descriptorIndex=" + descriptorIndex +
                ",name=" + getName() +
                ", descriptor=" + getDescriptorValue() +
                '}';
    }
}
